//
//  UIImageView+Extension.swift
//  WeiBo
//
//  Created by 张德华 on 7/24/16.
//  Copyright © 2016 ZhangDeHua. All rights reserved.
//

import UIKit


extension UIImageView {
    
    
    
    func wq_setImage(urlString: String?, placeholderName: String?) {
        
        ///------ 准备占位图片
        var placeholderImage: UIImage?
        if placeholderName != nil {
            placeholderImage = UIImage(named: placeholderName!)
        }
        
        ///------ 判断是否要网络获取图片
        guard let urlString = urlString, let url = NSURL(string: urlString) else {
            ///------ 如果url 为nil,但是有占位图片,显示占位图片
            image = placeholderImage
            return
        }
        
        sd_setImageWithURL(url, placeholderImage: placeholderImage)
        
//        sd_setImageWithURL(NSURL(string: WQUserAccountModel.sharedUserAccount.avatar_large!), placeholderImage: UIImage(named: "ad_background"))
    }
    
    
}